import React from 'react';
// import { Button, Form, Input } from 'antd';
import "./index.css"
import {getDengApi} from '../../api/deng'
import { useNavigate } from 'react-router-dom';
import { Button, Form, Input } from 'antd';

const App: React.FC = () => {
    const navigate=useNavigate()
    // console.log(useNavigate());
    
  const onFinish = (values: any) => {
    console.log( values.username);
    console.log( values.password);

    // useEffect(() => {
        getDengApi({
            username:values.username,
            password:values.password
        })
          .then((data: any) => {
            if(data!=""){
                // history.push({pathname:'/Home/zhaopinxinxi'})
                navigate('/Home');
            }
          })
    //   })




  };

  const onFinishFailed = (errorInfo: any) => {
    // console.log('Failed:', errorInfo);
  };

  return (
    <Form
      name="basic"
      labelCol={{ span: 8 }}
      wrapperCol={{ span: 16 }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
      autoComplete="off"
    >
      <Form.Item
        label="Username"
        name="username"
        rules={[{ required: true, message: '请输入账账户' }]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="Password"
        name="password"
        rules={[{ required: true, message: '请输入密码' }]}
      >
        <Input.Password />
      </Form.Item>

      <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
        <Button type="primary" htmlType="submit">
          登录
        </Button>
      </Form.Item>
    </Form>
  );
};

export default App;